package cn.xaut.XAUT迎春杯预热;

import java.util.Scanner;
import static java.lang.Math.*;

/**
 * I - ProjectEuler 3
 */
public class demoI {

    static boolean isPrime(long n) {

        for (int i = 2; i <= sqrt(n); i++) {
            if (n % i == 0)
                return false;
        }
        return true;
    }
    
    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

        int T = input.nextInt();
        for (int i = 0; i < T; i++) {
            long n = input.nextLong();
            long res = 0;
            for (long j = 2; j <= n; j++) {
                while (n % j == 0 && isPrime(j)) {
                    res = j;
                    n /= j;
                }
            }
            System.out.println(res);
        }
        
    }
}
